package com.cci.kangdao.dao;

import java.util.List;
import java.util.Map;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;
import org.mybatis.spring.annotation.MapperScan;

import com.cci.kangdao.dao.model.EngineMsg;

/**
 * 发动机类dao
 *
 */
@MapperScan
public interface EngineMsgDao {


	/**
	 * 根据equipmentNo查询发动机表中唯一数据
	 * @param map
	 * @return
	 */
	@Select("select * from EngineMsg where ESN = #{ESN}")
	EngineMsg getEngineMsgByESN(Map<String, Object> map);


	/**
	 * 根据equipmentNo查询发动机表中唯一数据
	 * @param map
	 * @return
	 */
	@Select("select * from EngineMsg where amtNo = #{amtNo}")
	EngineMsg getEngineMsgByAmtNo(Map<String, Object> map);


	@Select("select top 1 engineType from EngineMsg where ESN = #{ESN}")
	String getEngineTypeByESN(String esn);

	//根据ESN号获取发动机信息
	@Select("select * from EngineMsg where ESN = #{ESN}")
	Map<String,Object> getSMNByESN(String ESN);

	@Select("select * from EngineMsg where AmtNo = #{amtNo} ")
	Map<String,Object> getSMNByAmtNo(String amtNo);
	@Select("select * from EngineMsg where ESN = #{ESN}")
	EngineMsg getEngineMsgByESNString(String ESN);

	/**
	 * 保存从CRM系统中返回来的数据到发动机信息表
	 * @param map
	 * @return
	 */
	int insertEngineMsg(Map<String, Object> map);


	int newInsertEngineMsg(Map<String, Object> map);

	/**
	 * 保存从CRM系统中返回来的数据到发动机信息表
	 * @param map
	 * @return
	 */
	int insertEngineMsgByAmt(Map<String, Object> map);

	/**
	 * 通过主键更新发动机信息
	 * @param map
	 * @return
	 */
	int updateEngineMsg(Map<String, Object> map);

	@Delete("delete from EngineMsg where id = #{id}")
	int deleteEngineMsgById(Long id);

	@Select("select * from EngineMsg where id = #{id}")
	EngineMsg getEngineMsgById(Long id);

	public int insertSelective(Map<String, Object> map);

	int insertBatchSelective(List<Map<String, Object>> map);

	/**
	 * 修改发动机信息表数据
	 * @param map
	 * @return
	 */
	int updateByPrimaryKeySelective(Map<String,Object> map);

	int updateBatchByPrimaryKeySelective(List<Map<String,Object>> mapList);


	int updateMsgByEsn(Map<String,Object> map);



}
